package com.frogs.ucenter.v1.request;

import javax.servlet.http.HttpServletRequest;

import com.frogs.framework.util.StringUtil;
import com.frogs.framework.web.HttpRequestInfo;
import com.frogs.system.util.ApiUrlParamEnum;
import com.frogs.system.web.api.request.Request;
import com.frogs.system.web.exception.RequestIllegalException;

/**
 * 账号邮箱验证请求参数类
 *
 * @author lijian
 * @version 2014年3月26日 - 下午7:28:37
 */
public class UserVerifyEmailRequest extends Request {

	/**
	 * 邮箱
	 */
	private String email;
	
	/** */
	public UserVerifyEmailRequest() {
	}
	
	@Override
	public void parse(HttpServletRequest request) {
		
		HttpRequestInfo requestInfo = new HttpRequestInfo(request);
		
		this.email = requestInfo.getParameter(ApiUrlParamEnum.email.getParamName(), "");
		if (StringUtil.isEmpty(email)) {
			throw new RequestIllegalException("邮箱不能为空");
		}
		if (!StringUtil.isEmpty(email) && !StringUtil.isEmail(email)) {
			throw new RequestIllegalException("邮箱格式有误");
		}
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

}
